// type:请求方式；url：请求地址；data：请求参数;dataType:数据交换格式;succCallback请求成功回调；errorCallback:请求失败回调。
function $ajax(type, url, data, dataType, succCallback, errorCallback) {
    var type = type || "post";
    var dataType = dataType || "json";
    var loading = '<div class="spinner" id="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>';
    $.ajax({
        type: type,
        url: url,
        data: data,
        dataType: dataType,
        async: true,
        beforeSend: function () {
            $('body').append(loading);
        },
        success: function (res) {
            succCallback(res);
        },
        error: function () {
            errorCallback();
        },
        complete: function () {
            $('#spinner').remove();
        }
    })
}

/**
 * 将来源的状态值转换成文字
 * 来源（0：微信公众号 1：阿拉警察APP）
 */
function getSource(source) {
    var sourceStr = "";
    if (source == 0) {
        sourceStr = "微信公众号"
    } else {
        sourceStr = "阿拉警察APP"
    }
    return sourceStr;
}

/**
 * 将审核状态的状态值转换成文字
 * 审核状态（0：待审核 1：通过 2：不通过）
 */
function getStatus(status) {
    var statusStr = "";
    if (status == 0) {
        statusStr = "待审核"
    } else if (status == 1 || status == 3) {
        statusStr = "审核通过"
    } else {
        statusStr = "审核驳回"
    }
    return statusStr;
}

/**
 * null转""
 */
function wipeNull(obj) {
    if (obj == null) {
        obj = "";
    }
    return obj;
}

/**
 * 将是否用餐的状态值转换成文字
 * 用餐状态（0：否 1：是）
 */
function getMealStatus(status) {
    var statusStr = "";
    if (status == 0) {
        statusStr = "否"
    } else {
        statusStr = "是"
    }
    return statusStr;
}

/**
 * 截取url地址中参数:用户唯一id
 * 用餐状态（0：否 1：是）
 */
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

/**
 * 时间戳格式化函数
 * 格式化的时间字符串
 */
function formatDate(now) {
    if (now != undefined) {
        var date = new Date(now);
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        return year + "-" + month + "-" + day;
    }
    return "";
}

// 审核不通过原因是否可用
$('#fd-selectSFD').change(function () {
    if ($('#fd-selectSFD').val() != '1') {
        $('#fd-selectYFD').removeAttr('disabled');
    } else {
        $('#fd-selectYFD').attr('disabled', 'disabled');
        $('#fd-selectYFD').val('');
    }
})

// 分页汇总
// 亲人会见-query
function PAGE_HOLE_QUERY_F(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                // data为3 时session失效，返回登录
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                // 查询后清除原有内容
                $('#fq-tbodyFQ').empty();
                // 添加新内容
                for (var i = 0; i < data.length; i++) {
                    var meetUserFQ = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].applyMobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + data[i].meetCount + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a  class='look Shen' href=./familyDetails.html?appointmentId=" + data[i].appointmentId + ">查看" + "</a>" + "<a class='new Shen'  href=./familyDetails.html?appointmentId=" + data[i].appointmentId + " data-live=" + data[i].sort + " data-auditStatus=" + data[i].auditStatus + ">重新审核" + "</a>" + '</td></tr>';
                    $('#fq-tbodyFQ').append(meetUserFQ);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.look').click(function () {
                    localStorage.LOOK_STATUS = 'yes';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'query';
                })
                $('.new').each(function () {
                    if ($(this).attr('data-live') == 0 || $(this).attr('data-auditStatus') == 3) {
                        $(this).addClass('pass');
                        $(this).attr('href', 'javascript:;');
                        $(this).css('background-color', '#999');
                        $(this).attr('disabled', true);
                    }
                })
                // 分页
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum, //当前页
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_QUERY_F('http://' + window.location.host + '/wsyypt/appointment/queryList', 1, pageNum, auditStatus, startDate, endDate, keyWord)
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 律师会见-query
function PAGE_HOLE_QUERY_L(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#lq-tbodyLQ').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserLM = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].meetUser.meetNm + '</td><td>' + data[i].meetUser.mobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='look Shen' href=./lawyerDetails.html?appointmentId=" + data[i].appointmentId + ">查看</a><a class='new Shen'  href=./lawyerDetails.html?appointmentId=" + data[i].appointmentId + " data-live=" + data[i].sort + " data-auditStatus=" + data[i].auditStatus + ">重新审核</a></td></tr>";
                    $('#lq-tbodyLQ').append(meetUserLM);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.look').click(function () {
                    localStorage.LOOK_STATUS = 'yes';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'query';
                })
                $('.new').each(function () {
                    if ($(this).attr('data-live') == 0 || $(this).attr('data-auditStatus') == 3) {
                        $(this).addClass('passTime');
                        $(this).attr('href', 'javascript:;');
                        $(this).css('background-color', '#999');
                        $(this).attr('disabled', true);
                    }
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_QUERY_L('http://' + window.location.host + '/wsyypt/appointment/queryList', 2, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 民警提讯-query
function PAGE_HOLE_QUERY_P(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#pq-tbodyPQ').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserPQ = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].meetUser.meetNm + '</td><td>' + data[i].meetUser.mobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + getMealStatus(data[i].meetUser.needMeal) + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='look Shen' href=./policeDetails.html?appointmentId=" + data[i].appointmentId + ">查看" + "</a>" + "<a class='new Shen' href=./policeDetails.html?appointmentId=" + data[i].appointmentId + " data-live=" + data[i].sort + " data-auditStatus=" + data[i].auditStatus + ">重新审核" + "</a>" + '</td></tr>';
                    $('#pq-tbodyPQ').append(meetUserPQ);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.look').click(function () {
                    localStorage.LOOK_STATUS = 'yes';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'query';
                })
                $('.new').each(function () {
                    if ($(this).attr('data-live') == 0 || $(this).attr('data-auditStatus') == 3) {
                        $(this).addClass('passTime');
                        $(this).attr('href', 'javascript:;');
                        $(this).css('background-color', '#999');
                        $(this).attr('disabled', true);
                    }
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_QUERY_P('http://' + window.location.host + '/wsyypt/appointment/queryList', 3, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 视频会见-query
function PAGE_HOLE_QUERY_V(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#vq-tbodyVQ').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserVQ = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].applyMobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='look Shen' href=./videoDetails.html?appointmentId=" + data[i].appointmentId + "&look=look>查看" + "</a>" + "<a class='new Shen' href=./videoDetails.html?appointmentId=" + data[i].appointmentId + " data-live=" + data[i].sort + " data-auditStatus=" + data[i].auditStatus + ">重新审核" + "</a>" + '</td></tr>';
                    $('#vq-tbodyVQ').append(meetUserVQ);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.look').click(function () {
                    localStorage.LOOK_STATUS = 'yes';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'query';
                })
                $('.new').each(function () {
                    if ($(this).attr('data-live') == 0 || $(this).attr('data-auditStatus') == 3) {
                        $(this).addClass('passTime');
                        $(this).attr('href', 'javascript:;');
                        $(this).css('background-color', '#999');
                        $(this).attr('disabled', true);
                    }
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_QUERY_V('http://' + window.location.host + '/wsyypt/appointment/queryList', 4, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 亲人会见-meet
function PAGE_HOLE_MEET_F(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#fm-tbodyFM').empty();
                $('#pagination').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserFM = '<tr data-id=' + data[i].appointmentId + '><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].applyMobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + data[i].meetCount + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='new Shen' href=./familyDetails.html?appointmentId=" + data[i].appointmentId + ">审核</a></td></tr>";
                    $('#fm-tbodyFM').append(meetUserFM);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'meet';
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_MEET_F('http://' + window.location.host + '/wsyypt/appointment/getMeetList', 1, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function (res) {
            alert('获取数据失败!')
        }
    )
}

// 律师会见-meet
function PAGE_HOLE_MEET_L(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#lm-tbodyLM').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserLM = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].meetUser.meetNm + '</td><td>' + data[i].meetUser.mobile + '</td><td>' + formatDate(data[i].appointmentTime) + '</td><td>' + wipeNull(formatDate(data[i].lastMeetTime)) + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='new Shen' href=./lawyerDetails.html?appointmentId=" + data[i].appointmentId + ">审核</a></td></tr>";
                    $('#lm-tbodyLM').append(meetUserLM);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'meet';
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_MEET_L('http://' + window.location.host + '/wsyypt/appointment/getMeetList', 2, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 民警提讯-meet
function PAGE_HOLE_MEET_P(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#pm-tbodyPM').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserPM = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].meetUser.meetNm + '</td><td>' + data[i].meetUser.mobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + getMealStatus(data[i].meetUser.needMeal) + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='new Shen' href=./policeDetails.html?appointmentId=" + data[i].appointmentId + ">审核</a></td></tr>";
                    $('#pm-tbodyPM').append(meetUserPM);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'meet';
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_MEET_P('http://' + window.location.host + '/wsyypt/appointment/getMeetList', 3, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 视频会见-meet
function PAGE_HOLE_MEET_V(URL, appointmentType, pageNum, auditStatus, startDate, endDate, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var appointmentType = appointmentType;
    var pageNum = pageNum || 1;
    var auditStatus = auditStatus || '';
    var startDate = startDate || '';
    var endDate = endDate || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'appointmentType': appointmentType,
            'pageNum': pageNum,
            'auditStatus': auditStatus,
            'startDate': startDate,
            'endDate': endDate,
            'keyWord': keyWord
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#vm-tbodyVM').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserVM = '<tr><td>' + (i + 1) + '</td><td>' + data[i].objUser.objNm + '</td><td>' + data[i].objUser.idNum + '</td><td>' + getSource(data[i].source) + '</td><td>' + data[i].applyMobile + '</td><td>' + formatDate(new Date(data[i].appointmentTime)) + '</td><td>' + data[i].meetCount + '</td><td>' + getStatus(data[i].auditStatus) + '</td><td>' + "<a class='new Shen' href=./videoDetails.html?appointmentId=" + data[i].appointmentId + ">审核</a></td></tr>";
                    $('#vm-tbodyVM').append(meetUserVM);
                }
                $('.new').click(function () {
                    localStorage.LOOK_STATUS = 'no';
                })
                $('.Shen').click(function () {
                    localStorage.meet_query = 'meet';
                })
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_MEET_V('http://' + window.location.host + '/wsyypt/appointment/getMeetList', 4, pageNum, auditStatus, startDate, endDate, keyWord);
                    }
                });
            }
        },
        function () {
            alert('获取数据失败!')
        }
    )
}

// 监所管理-
function PAGE_HOLE_ORG(URL, pageNum, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var pageNum = pageNum || 1;
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'orgNm': keyWord,
            'pageNum': pageNum
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#org-tbodyORG').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetUserORG = '<tr><td>' + (i + 1) + '</td><td  id="orgNm">' + data[i].orgNm + '</td><td id="contacts">' + data[i].contacts + '</td><td id="contactsMobile">' + data[i].contactsMobile + '</td><td id="orgAddress">' + data[i].orgAddress + '</td><td>' + "<a href='javascript:;' class='bianji' data-orgId='" + data[i].orgId + "' data-toggle='modal' data-target='#orgModal2'>" + '编辑' + "</a>" + "<a href='javascript:;' data-orgId=" + data[i].orgId + " class='Del Delete'>" + '删除' + "</a>" + '</td></tr>';
                    $('#org-tbodyORG').append(meetUserORG);
                }
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_ORG('http://' + window.location.host + '/wsyypt/Org/queryList', pageNum, keyWord);
                    }
                });
                var orgId = '';
                localStorage.SendCountO = 0;
                localStorage.AlertCountOB = 0;
                $('.bianji').click(function () {
                    $('#OrgNmB').val('');
                    $('#ContactsB').val('');
                    $('#ContactsMobileB').val('');
                    $('#OrgAddressB').val('');
                    orgId = $(this).attr('data-orgId');
                    var orgNm1 = $(this).parent().parent().children('#orgNm').text();
                    var contacts1 = $(this).parent().parent().children('#contacts').text();
                    var contactsMobile1 = $(this).parent().parent().children('#contactsMobile').text();
                    var orgAddress1 = $(this).parent().parent().children('#orgAddress').text();
                    $('#OrgNmB').val(orgNm1);
                    $('#ContactsB').val(contacts1);
                    $('#ContactsMobileB').val(contactsMobile1);
                    $('#OrgAddressB').val(orgAddress1);
                    localStorage.AlertCountOB = 0;
                    $("#Edit").one('click', function () {
                        orgEdit();

                        function orgEdit() {
                            setTimeout(function () {
                                localStorage.AlertCountOB = 0;
                                localStorage.SendCountO = 0;
                            }, '500');
                            localStorage.SendCountO++;
                            localStorage.AlertCountOB++;
                            var orgNm2 = $('#OrgNmB').val();
                            var contacts2 = $('#ContactsB').val();
                            var contactsMobile2 = $('#ContactsMobileB').val();
                            var orgAddress2 = $('#OrgAddressB').val();
                            if (orgNm2 == '') {
                                if (localStorage.AlertCountOB == 1) {
                                    alert('请填写监所名称！')
                                    localStorage.SendCountO = 0;
                                    localStorage.AlertCountOB = -100;
                                    $("#Edit").one('click', function () {
                                        orgEdit();
                                    })
                                } else {
                                    return
                                }
                            } else if (contacts2 == '') {
                                if (localStorage.AlertCountOB == 1) {
                                    alert('请填写联系人！')
                                    localStorage.SendCountO = 0;
                                    localStorage.AlertCountOB = -100;
                                    $("#Edit").one('click', function () {
                                        orgEdit();
                                    })
                                } else {
                                    return
                                }
                            } else if (!(/^1[34578]\d{9}$/.test(contactsMobile2))) {
                                if (localStorage.AlertCountOB == 1) {
                                    if (contactsMobile2 == '') {
                                        alert('请填写手机号码！')
                                        localStorage.SendCountO = 0;
                                        localStorage.AlertCountOB = -100;
                                        $("#Edit").one('click', function () {
                                            orgEdit();
                                        })
                                    } else {
                                        alert('请填写正确的手机号码！')
                                        localStorage.SendCountO = 0;
                                        localStorage.AlertCountOB = -100;
                                        $("#Edit").one('click', function () {
                                            orgEdit();
                                        })
                                    }
                                } else {
                                    return
                                }
                            } else if (orgAddress2 == '') {
                                if (localStorage.AlertCountOB == 1) {
                                    alert('请填写地址！')
                                    localStorage.SendCountO = 0;
                                    localStorage.AlertCountOB = -100;
                                    $("#Edit").one('click', function () {
                                        orgEdit();
                                    })
                                } else {
                                    return
                                }
                            } else {
                                if (localStorage.SendCountO == 1) {
                                    $ajax('post',
                                        'http://' + window.location.host + '/wsyypt/Org/edit', {
                                            "orgId": orgId,
                                            "orgNm": orgNm2,
                                            "contacts": contacts2,
                                            "contactsMobile": contactsMobile2,
                                            "orgAddress": orgAddress2
                                        },
                                        'json',
                                        function (data) {
                                            localStorage.SendCountO = 0;
                                            if (data == 1) {
                                                alert('编辑成功！')
                                                $('#OrgNmB').val('');
                                                $('#ContactsB').val('');
                                                $('#ContactsMobileB').val('');
                                                $('#OrgAddressB').val('');
                                                $('#orgModal2').modal('hide');
                                                PAGE_HOLE_ORG('http://' + window.location.host + '/wsyypt/Org/queryList', pageNum, keyWord);
                                            } else {
                                                alert("编辑失败！");
                                                $('#OrgNmB').val('');
                                                $('#ContactsB').val('');
                                                $('#ContactsMobileB').val('');
                                                $('#OrgAddressB').val('');
                                                $('#orgModal2').modal('hide');
                                            }
                                        },
                                        function () {
                                            alert('操作失败！')
                                            localStorage.SendCountO = 0;
                                            $('#OrgNmB').val('');
                                            $('#ContactsB').val('');
                                            $('#ContactsMobileB').val('');
                                            $('#OrgAddressB').val('');
                                            $('#orgModal2').modal('hide');
                                        }
                                    )
                                }
                            }
                        }
                    })
                })
            }
            $(".Del").click(function () {
                orgId2 = $(this).attr('data-orgId');
                var msg = '是否确认删除？';
                if (confirm(msg) == true) {
                    $ajax('post',
                        'http://' + window.location.host + '/wsyypt/Org/delete', {
                            "orgId": orgId2
                        },
                        'json',
                        function (data) {
                            if (data == 1) {
                                $(this).parent().parent().remove();
                                alert("删除成功");
                                PAGE_HOLE_ORG('http://' + window.location.host + '/wsyypt/Org/queryList', pageNum, keyWord);
                            } else {
                                alert("操作失败!");
                            }
                        },
                        function () {
                            alert('操作失败！')
                        }
                    )
                } else {
                    return false;
                }
            })
        },
        function () {
            alert('操作失败！')
        }
    )
}

// 用户管理-user
function PAGE_HOLE_USER(URL, pageNum, orgId, keyWord) {
    $('#pagination').empty();
    var URL = URL;
    var pageNum = pageNum || 1;
    var orgId = orgId || '';
    var keyWord = keyWord || '';
    $ajax('post',
        URL, {
            'orgId': orgId,
            'keyWord': keyWord,
            'pageNum': pageNum
        },
        'json',
        function (data) {
            if (data.sign == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#User-select').empty();
                var userSelectO = '';
                var selfSelect = '<option value="">全部监所</option>';
                for (var j = 0; j < data.orgList.length; j++) {
                    userSelectO = userSelectO + '<option value=' + data.orgList[j].orgId + '>' + data.orgList[j].orgNm + '</option>';
                }
                SelectO = selfSelect + userSelectO;
                $('#User-select').append(SelectO);
                if (localStorage.orgId == '') {
                    $('#User-select').val('');
                } else {
                    $('#User-select').val(orgId);
                    localStorage.orgId = orgId;
                }
                $('#user-tbodyU').empty();
                for (var i = 0; i < data.userList.length; i++) {
                    var meetUserU = '<tr><td>' + (i + 1) + '</td><td id="account">' + data.userList[i].account + '</td><td  id="userNm">' + data.userList[i].userNm + '</td><td id="contactsMobile">' + data.userList[i].contactsMobile + '</td><td id="orgNm">' + data.userList[i].orgNm + '</td><td id="createTime">' + formatDate(data.userList[i].createTime) + '</td><td>' + "<a href='javascript:;' class='bianji' data-userId='" + data.userList[i].userId + "' data-toggle='modal' data-target='#userModal2' class='Edit'>" + '编辑' + "</a>" + "<a href='javascript:;' data-userId=" + data.userList[i].userId + " class='Del Delete'>" + '删除' + "</a>" + '</td></tr>';
                    $('#user-tbodyU').append(meetUserU);
                }
                $('.M-box3').pagination({
                    pageCount: data.pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data.pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_USER('http://' + window.location.host + '/wsyypt/SysUser/queryList', pageNum, orgId, keyWord)
                    }
                });
            }
            var userId = '';
            localStorage.SendCountUE = 0;
            $('.bianji').click(function () {
                localStorage.AlertCountUB = 0;
                userId = $(this).attr('data-userId');
                $ajax('post', 'http://' + window.location.host + '/wsyypt/SysUser/querySysUser', {
                        'userId': userId
                    },
                    'json',
                    function (data) {
                        if (data == 3) {
                            alert('登录过期，请重新登录！')
                            parent.location.href = '../index-inner.html';
                        } else {
                            $('#OrgIdB').empty();
                            var userSelect = '';
                            var selfSelect = '<option value="">----请选择----</option>';
                            for (var j = 0; j < data.orgList.length; j++) {
                                userSelect = userSelect + '<option value=' + data.orgList[j].orgId + '>' + data.orgList[j].orgNm + '</option>';
                            }
                            Select = selfSelect + userSelect;
                            $('#OrgIdB').append(Select);
                            $('#OrgRoleB').empty();
                            var userSelectB = '';
                            for (var k = 0; k < data.roleList.length; k++) {
                                userSelectB = userSelectB + '<option value=' + data.roleList[k].roleId + '>' + data.roleList[k].roleNm + '</option>';
                            }
                            SelectB = selfSelect + userSelectB;
                            $('#OrgRoleB').append(SelectB);
                            $('#AccountB').val(data.user.account);
                            $('#PasswordB').val(data.user.password);
                            $('#UserNmB').val(data.user.userNm);
                            $('#ContactsMobileB').val(data.user.contactsMobile);
                            $('#OrgIdB').val(data.user.orgId);
                            $('#OrgRoleB').val(data.user.roleId);
                        }
                    },
                    function () {})
                localStorage.AlertCountUB = 0;
                $("#Edit").one('click', function () {
                    userEdit();

                    function userEdit() {
                        setTimeout(function () {
                            localStorage.AlertCountUB = 0;
                            localStorage.SendCountUE = 0;
                        }, '500');
                        localStorage.SendCountUE++;
                        localStorage.AlertCountUB++;
                        var accountB = $('#AccountB').val();
                        var passwordB = $('#PasswordB').val();
                        var userNmB = $('#UserNmB').val();
                        var contactsMobileB = $('#ContactsMobileB').val();
                        var orgIdB = $("#OrgIdB option:selected").val();
                        var orgRoleB = $("#OrgRoleB option:selected").val();
                        if (accountB == '') {
                            if (localStorage.AlertCountUB == 1) {
                                alert('请填写用户名！')
                                localStorage.SendCountUE = 0;
                                localStorage.AlertCountUB = -100;
                                $("#Edit").one('click', function () {
                                    userEdit();
                                })
                            } else {
                                return
                            }
                        } else if (passwordB == '') {
                            if (localStorage.AlertCountUB == 1) {
                                alert('请填写登录密码！')
                                localStorage.SendCountUE = 0;
                                localStorage.AlertCountUB = -100;
                                $("#Edit").one('click', function () {
                                    userEdit();
                                })
                            } else {
                                return
                            }
                        } else if (userNmB == '') {
                            if (localStorage.AlertCountUB == 1) {
                                alert('请填写真实姓名！')
                                localStorage.SendCountUE = 0;
                                localStorage.AlertCountUB = -100;
                                $("#Edit").one('click', function () {
                                    userEdit();
                                })
                            } else {
                                return
                            }
                        } else if (!(/^1[34578]\d{9}$/.test(contactsMobileB))) {
                            if (localStorage.AlertCountUB == 1) {
                                if (contactsMobileB == '') {
                                    alert('请填写手机号码！')
                                    localStorage.SendCountUE = 0;
                                    localStorage.AlertCountUB = -100;
                                    $("#Edit").one('click', function () {
                                        userEdit();
                                    })
                                } else {
                                    alert('请填写正确的手机号码！')
                                    localStorage.SendCountUE = 0;
                                    localStorage.AlertCountUB = -100;
                                    $("#Edit").one('click', function () {
                                        userEdit();
                                    })
                                }
                            } else {
                                return
                            }
                        } else if (orgIdB == '') {
                            if (localStorage.AlertCountUB == 1) {
                                alert('请选择所属监所！')
                                localStorage.SendCountUE = 0;
                                localStorage.AlertCountUB = -100;
                                $("#Edit").one('click', function () {
                                    userEdit();
                                })
                            } else {
                                return
                            }
                        } else if (orgRoleB == '') {
                            if (localStorage.AlertCountUB == 1) {
                                alert('请选择角色！')
                                localStorage.SendCountUE = 0;
                                localStorage.AlertCountUB = -100;
                                $("#Edit").one('click', function () {
                                    userEdit();
                                })
                            } else {
                                return
                            }
                        } else {
                            if (localStorage.SendCountUE == 1) {
                                $ajax('post',
                                    'http://' + window.location.host + '/wsyypt/SysUser/edit', {
                                        "userId": userId,
                                        "account": accountB,
                                        "password": passwordB,
                                        "userNm": userNmB,
                                        "contactsMobile": contactsMobileB,
                                        "orgId": orgIdB,
                                        "roleId": orgRoleB
                                    },
                                    'json',
                                    function (data) {
                                        localStorage.SendCountUE = 0;
                                        if (data == 1) {
                                            alert("编辑成功！");
                                            $('#AccountB').val('');
                                            $('#PasswordB').val('');
                                            $('#UserNmB').val('');
                                            $('#ContactsMobileB').val('');
                                            $('#OrgIdB').val('');
                                            $('#orgRoleB').val('');
                                            $('#userModal2').modal('hide');
                                            PAGE_HOLE_USER('http://' + window.location.host + '/wsyypt/SysUser/queryList', pageNum, orgId, keyWord)
                                        } else {
                                            alert("编辑失败！");
                                            $('#AccountB').val('');
                                            $('#PasswordB').val('');
                                            $('#UserNmB').val('');
                                            $('#ContactsMobileB').val('');
                                            $('#OrgIdB').val('');
                                            $('#orgRoleB').val('');
                                            $('#userModal2').modal('hide');
                                        }
                                    },
                                    function () {
                                        alert('编辑失败！')
                                        localStorage.SendCountUE = 0;
                                        $('#AccountB').val('');
                                        $('#PasswordB').val('');
                                        $('#UserNmB').val('');
                                        $('#ContactsMobileB').val('');
                                        $('#OrgIdB').val('');
                                        $('#orgRoleB').val('');
                                        $('#userModal2').modal('hide');
                                    }
                                )
                            }
                        }
                    }
                })
            })
            $(".Del").click(function () {
                var userId = $(this).attr('data-userId');
                var msg = '是否确认删除？';
                if (confirm(msg) == true) {
                    $ajax('post',
                        'http://' + window.location.host + '/wsyypt/SysUser/delete', {
                            "userId": userId
                        },
                        'json',
                        function (data) {
                            if (data == 1) {
                                $(this).parent().parent().remove();
                                alert("删除成功！");
                                PAGE_HOLE_USER('http://' + window.location.host + '/wsyypt/SysUser/queryList', pageNum, orgId, keyWord)
                            } else {
                                alert("删除失败！");
                            }
                        },
                        function () {
                            alert('操作失败！')
                        }
                    )
                } else {
                    return false;
                }
            })
        },
        function () {
            alert('操作失败！')
        }
    )
}

// 角色管理-role
function PAGE_HOLE_ROLE(URL, pageNum, roleNm) {
    $('#limits2').empty();
    $('#pagination').empty();
    var checkBOX = [];
    var URL = URL;
    var pageNum = pageNum || 1;
    var roleNm = roleNm || '';
    $ajax('post',
        'http://' + window.location.host + '/wsyypt/Role/queryList', {
            'roleNm': roleNm,
            'pageNum': pageNum
        },
        'json',
        function (data) {
            if (data == 3) {
                alert('登录过期，请重新登录！')
                parent.location.href = '../index-inner.html';
            } else if (data.length == 0) {
                alert('未搜索到符合条件的记录！')
            } else {
                $('#role-tbodyR').empty();
                for (var i = 0; i < data.length; i++) {
                    var meetRole = '<tr><td>' + (i + 1) + '</td><td id="roleNm">' + data[i].roleNm + '</td><td id="roleDesc">' + data[i].roleDesc + '</td><td>' + "<a href='javascript:;' class='bianji' data-roleId='" + data[i].roleId + "' data-toggle='modal' data-target='#roleModal2'>" + '编辑' + "</a>" + "<a href='javascript:;' data-roleId=" + data[i].roleId + " class='Del Delete'>" + '删除' + "</a>" + '</td></tr>';

                    $('#role-tbodyR').append(meetRole);
                }
                $('.M-box3').pagination({
                    pageCount: data[0].pageInfo.pageCount,
                    jump: true,
                    coping: true,
                    current: pageNum,
                    homePage: '首页',
                    endPage: '末页',
                    prevContent: '上页',
                    nextContent: '下页',
                    totalData: data[0].pageInfo.numbers,
                    showData: 10,
                    callback: function (api) {
                        pageNum = api.getCurrent();
                        PAGE_HOLE_ROLE('http://' + window.location.host + '/wsyypt/Role/queryList', pageNum, roleNm)
                    }
                });
            }
            var roleId = '';
            localStorage.SendCountE = 0;
            $('.bianji').click(function () {
                localStorage.AlertCountB = 0;
                $('#limits2').empty();
                roleId = $(this).attr('data-roleId');
                $ajax('post', 'http://' + window.location.host + '/wsyypt/Menu/queryMenu', '', 'json', function (data) {
                    var aside_div_header = '<div class="role-first">';
                    var yuyue_DIV = '',
                        yuyue_DIV2 = '',
                        All_div = '';
                    start_DIV = aside_div_header + '<div><input id="role-dA" type="checkbox" data-id=' + data[0].sysMenuId + '><span>' + data[0].menuNm + '</span></div>' + '</div>';
                    if (data[1].menuNm == '预约审核') {
                        var yuyue_head = '<div id="role-tog1"><input type="checkbox" id="role-dB" data-id=' + data[1].sysMenuId + '><span>' + data[1].menuNm + '</span></div>';
                        var small_head = '<div class="role-add" id="role-dis1">';
                        var small_div = '';
                        for (var j = 0; j < data[1].menuList.length; j++) {
                            small_div += '<div><input type="checkbox" id="role-d' + (j + 1) + '" data-id=' + data[1].menuList[j].sysMenuId + '><span>' + data[1].menuList[j].menuNm + '</span></div>';
                        }
                        yuyue_DIV = aside_div_header + yuyue_head + small_head + small_div + '</div></div></div>';
                    }
                    if (data[2].menuNm == '预约查询') {
                        var yuyue_head2 = '<div id="role-tog2"><input type="checkbox" id="role-dC" data-id=' + data[2].sysMenuId + '><span>' + data[2].menuNm + '</span></div>';
                        var small_head = '<div class="role-add" id="role-dis2">';
                        var small_div = '';
                        for (var j = 0; j < data[2].menuList.length; j++) {
                            small_div += '<div><input type="checkbox" id="role-d' + (j + 5) + '" data-id=' + data[2].menuList[j].sysMenuId + '><span>' + data[2].menuList[j].menuNm + '</span></div>';
                        }
                        yuyue_DIV2 = aside_div_header + yuyue_head2 + small_head + small_div + '</div></div></div>';
                    }
                    if (data[3].menuNm == '系统管理') {
                        var yuyue_head3 = '<div id="role-tog3"><input type="checkbox" id="role-dD" data-id=' + data[3].sysMenuId + '><span>' + data[3].menuNm + '</span></div>';
                        var small_head = '<div class="role-add" id="role-dis3">';
                        var small_div = '';
                        for (var j = 0; j < data[3].menuList.length; j++) {
                            small_div += '<div><input type="checkbox" id="role-d' + (j + 9) + '" data-id=' + data[3].menuList[j].sysMenuId + '><span>' + data[3].menuList[j].menuNm + '</span></div>';
                        }
                        yuyue_DIV3 = aside_div_header + yuyue_head3 + small_head + small_div + '</div></div></div>';
                    }
                    All_div = start_DIV + yuyue_DIV + yuyue_DIV2 + yuyue_DIV3 + '</div>';
                    $('#limits2').append(All_div);
                    $('#role-tog1').on('click', function () {
                        $('#role-dis1').toggle()
                    })
                    $('#role-tog2').on('click', function () {
                        $('#role-dis2').toggle()
                    })
                    $('#role-tog3').on('click', function () {
                        $('#role-dis3').toggle()
                    })
                    $ajax(
                        'post',
                        'http://' + window.location.host + '/wsyypt/Role/queryRole', {
                            "roleId": roleId
                        },
                        'json',
                        function (data) {
                            $('#role-name').val(data.roleNm);
                            $('#role-desc').val(data.roleDesc);
                            var arr_checked = data.menuId.split(",");
                            for (var k = 0; k < $('#limits2 input[type="checkbox"]').length; k++) {
                                $.each(arr_checked, function (index, value) {
                                    if ($('#limits2 input[type="checkbox"]').eq(k).attr('data-id') == value) {
                                        $('#limits2 input[type="checkbox"]').eq(k).prop('checked', true);
                                        $(this).prop('checked', true);
                                    }
                                })
                            }
                            $('#role-dB').click(function () {
                                if ($('#role-dB').prop('checked') == true) {
                                    localStorage.dB = 1;
                                } else {
                                    localStorage.dB = 0;
                                }
                                if (localStorage.dB == 1) {
                                    $('#role-d1').prop('checked', true);
                                    $('#role-d2').prop('checked', true);
                                    $('#role-d3').prop('checked', true);
                                    $('#role-d4').prop('checked', true);
                                } else {
                                    $('#role-d1').removeAttr('checked');
                                    $('#role-d2').removeAttr('checked');
                                    $('#role-d3').removeAttr('checked');
                                    $('#role-d4').removeAttr('checked');
                                }

                            })
                            $('#role-d1').click(function () {
                                if ($('#role-d1').prop('checked') == true || $('#role-d2').prop('checked') == true || $('#role-d3').prop('checked') == true || $('#role-d4').prop('checked') == true) {
                                    $('#role-dB').prop('checked', true)
                                } else {
                                    $('#role-dB').removeAttr('checked');
                                }
                            })
                            $('#role-d2').click(function () {
                                if ($('#role-d1').prop('checked') == true || $('#role-d2').prop('checked') == true || $('#role-d3').prop('checked') == true || $('#role-d4').prop('checked') == true) {
                                    $('#role-dB').prop('checked', true)
                                } else {
                                    $('#role-dB').removeAttr('checked');
                                }
                            })
                            $('#role-d3').click(function () {
                                if ($('#role-d1').prop('checked') == true || $('#role-d2').prop('checked') == true || $('#role-d3').prop('checked') == true || $('#role-d4').prop('checked') == true) {
                                    $('#role-dB').prop('checked', true)
                                } else {
                                    $('#role-dB').removeAttr('checked');
                                }
                            })
                            $('#role-d4').click(function () {
                                if ($('#role-d1').prop('checked') == true || $('#role-d2').prop('checked') == true || $('#role-d3').prop('checked') == true || $('#role-d4').prop('checked') == true) {
                                    $('#role-dB').prop('checked', true)
                                } else {
                                    $('#role-dB').removeAttr('checked');
                                }
                            })

                            $('#role-dC').click(function () {
                                if ($('#role-dC').prop('checked') == true) {
                                    localStorage.dC = 1; //1勾选，0未选
                                } else {
                                    localStorage.dC = 0;
                                }
                                if (localStorage.dC == 1) {
                                    $('#role-d5').prop('checked', true);
                                    $('#role-d6').prop('checked', true);
                                    $('#role-d7').prop('checked', true);
                                    $('#role-d8').prop('checked', true);
                                } else {
                                    $('#role-d5').removeAttr('checked');
                                    $('#role-d6').removeAttr('checked');
                                    $('#role-d7').removeAttr('checked');
                                    $('#role-d8').removeAttr('checked');
                                }
                            })
                            $('#role-d5').click(function () {
                                if ($('#role-d5').prop('checked') == true || $('#role-d6').prop('checked') == true || $('#role-d7').prop('checked') == true || $('#role-d8').prop('checked') == true) {
                                    $('#role-dC').prop('checked', true)
                                } else {
                                    $('#role-dC').removeAttr('checked');
                                }
                            })
                            $('#role-d6').click(function () {
                                if ($('#role-d5').prop('checked') == true || $('#role-d6').prop('checked') == true || $('#role-d7').prop('checked') == true || $('#role-d8').prop('checked') == true) {
                                    $('#role-dC').prop('checked', true)
                                } else {
                                    $('#role-dC').removeAttr('checked');
                                }
                            })
                            $('#role-d7').click(function () {
                                if ($('#role-d5').prop('checked') == true || $('#role-d6').prop('checked') == true || $('#role-d7').prop('checked') == true || $('#role-d8').prop('checked') == true) {
                                    $('#role-dC').prop('checked', true)
                                } else {
                                    $('#role-dC').removeAttr('checked');
                                }
                            })
                            $('#role-d8').click(function () {
                                if ($('#role-d5').prop('checked') == true || $('#role-d6').prop('checked') == true || $('#role-d7').prop('checked') == true || $('#role-d8').prop('checked') == true) {
                                    $('#role-dC').prop('checked', true)
                                } else {
                                    $('#role-dC').removeAttr('checked');
                                }
                            })
                            $('#role-dD').click(function () {
                                if ($('#role-dD').prop('checked') == true) {
                                    localStorage.dD = 1;
                                } else {
                                    localStorage.dD = 0;
                                }
                                if (localStorage.dD == 1) {
                                    $('#role-d9').prop('checked', true);
                                    $('#role-d10').prop('checked', true);
                                    $('#role-d11').prop('checked', true);
                                } else {
                                    $('#role-d9').removeAttr('checked');
                                    $('#role-d10').removeAttr('checked');
                                    $('#role-d11').removeAttr('checked');
                                }
                            })
                            $('#role-d9').click(function () {
                                if ($('#role-d9').prop('checked') == true || $('#role-d10').prop('checked') == true || $('#role-d11').prop('checked') == true) {
                                    $('#role-dD').prop('checked', true)
                                } else {
                                    $('#role-dD').removeAttr('checked');
                                }
                            })
                            $('#role-d10').click(function () {
                                if ($('#role-d9').prop('checked') == true || $('#role-d10').prop('checked') == true || $('#role-d11').prop('checked') == true) {
                                    $('#role-dD').prop('checked', true)
                                } else {
                                    $('#role-dD').removeAttr('checked');
                                }
                            })
                            $('#role-d11').click(function () {
                                if ($('#role-d9').prop('checked') == true || $('#role-d10').prop('checked') == true || $('#role-d11').prop('checked') == true) {
                                    $('#role-dD').prop('checked', true)
                                } else {
                                    $('#role-dD').removeAttr('checked');
                                }
                            })
                        },
                        function () {
                            alert('操作失败！')
                        }
                    )
                });
                localStorage.AlertCountB = 0;
                $("#Edit").one('click', function () {
                    edit();

                    function edit() {
                        setTimeout(function () {
                            localStorage.AlertCountB = 0;
                            localStorage.SendCountE = 0;
                        }, '500');
                        localStorage.SendCountE++;
                        localStorage.AlertCountB++;
                        var roleNm2 = $('#role-name').val();
                        var roleDesc = $('#role-desc').val();
                        var authHome;
                        if (roleNm2 == '') {
                            if (localStorage.AlertCountB == 1) {
                                alert('请填写角色名！')
                                localStorage.SendCountE = 0;
                                localStorage.AlertCountB = -100;
                                $("#Edit").one('click', function () {
                                    edit();
                                })
                            } else {
                                return;
                            }
                        } else if (roleDesc == '') {
                            if (localStorage.AlertCountB == 1) {
                                alert('请填写角色说明！')
                                localStorage.SendCountE = 0;
                                localStorage.AlertCountB = -100;
                                $("#Edit").one('click', function () {
                                    edit();
                                })
                            } else {
                                return
                            }
                        } else if (($('#role-dA').prop('checked') == false && $('#role-d1').prop('checked') == false && $('#role-d2').prop('checked') == false && $('#role-d3').prop('checked') == false && $('#role-d4').prop('checked') == false && $('#role-d5').prop('checked') == false && $('#role-d6').prop('checked') == false && $('#role-d7').prop('checked') == false && $('#role-d8').prop('checked') == false && $('#role-d9').prop('checked') == false && $('#role-d10').prop('checked') == false && $('#role-d11').prop('checked') == false)) {
                            if (localStorage.AlertCountB == 1) {
                                alert('请选择角色权限！')
                                localStorage.SendCountE = 0;
                                localStorage.AlertCountB = -100;
                                $("#Edit").one('click', function () {
                                    edit();
                                })
                            } else {
                                return
                            }
                        } else {
                            checkBOX = [];
                            $('#roleModal2 input[type="checkbox"]:checked').each(function () {
                                checkBOX.push($(this).attr('data-id'));
                            })
                            checkBOX = checkBOX.toString();
                            if (localStorage.SendCountE == 1) {
                                $ajax('post',
                                    'http://' + window.location.host + '/wsyypt/Role/edit', {
                                        "roleId": roleId,
                                        "roleNm": roleNm2,
                                        "roleDesc": roleDesc,
                                        'menuId': checkBOX,
                                    },
                                    'json',
                                    function (data) {
                                        localStorage.SendCountE = 0;
                                        if (data == 1) {
                                            alert("编辑成功！");
                                            $('#role-name').val('');
                                            $('#role-desc').val('');
                                            $('#roleModal2 input[type="checkbox"]:checked').each(function () {
                                                $(this).removeAttr('checked');
                                            })
                                            $('#roleModal2').modal('hide');
                                            PAGE_HOLE_ROLE('http://' + window.location.host + '/wsyypt/Role/queryList', 1, roleNm)
                                        } else {
                                            alert("编辑失败！");
                                            $('#role-name').val('');
                                            $('#role-desc').val('');
                                            $('#roleModal2 input[type="checkbox"]:checked').each(function () {
                                                $(this).removeAttr('checked');
                                            })
                                            $('#roleModal2').modal('hide');
                                        }
                                    },
                                    function () {
                                        alert('操作失败！')
                                        localStorage.SendCountE = 0;
                                        checkBOX = [];
                                        $('#role-name').val('');
                                        $('#role-desc').val('');
                                        $('#roleModal2 input[type="checkbox"]:checked').each(function () {
                                            $(this).removeAttr('checked');
                                        })
                                        $('#roleModal2').modal('hide');
                                    }
                                )
                            }
                        }
                    }
                })
            })
            $(".Del").click(function () {
                var roleId = $(this).attr('data-roleId');
                var msg = '是否确认删除？';
                if (confirm(msg) == true) {
                    $ajax('post',
                        'http://' + window.location.host + '/wsyypt/Role/delete', {
                            "roleId": roleId
                        },
                        'json',
                        function (data) {
                            if (data == 1) {
                                $(this).parent().parent().remove();
                                alert("删除成功！");
                                PAGE_HOLE_ROLE('http://' + window.location.host + '/wsyypt/Role/queryList', 1, roleNm)
                            } else {
                                alert("操作失败！");
                            }
                        },
                        function () {
                            alert('操作失败！')
                        }
                    )
                } else {
                    return false;
                }
            })
        },
        function () {
            alert('操作失败！')
        }
    )
}